<?php
/*
EASY DONATE
by SCOTT ALLAN WALLICK, http://scottwallick.com/
from PLAINTXT.ORG, http://www.plaintxt.org/

This file is part of EASY DONATE.

EASY DONATE is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.

EASY DONATE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for details.

You should have received a copy of the GNU General Public License
along with EASY DONATE. If not, see www.gnu.org/licenses/.
*/

// Allow localization, if applicable
load_plugin_textdomain('easy_donate');
// Let them donate, if they will
if ( !function_exists('plaintxt_plugin_donate') ) {
	// If another plaintxt.org plugin is initialized before this one, use its donate function instead
	function plaintxt_plugin_donate() {
		$button = '
			<form id="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="float:left;margin:0.9em 0.5em 0 0;">
				<div id="donate">
					<input name="cmd" type="hidden" value="_s-xclick" />
					<input name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" type="image" alt="' . __( 'PayPal: The safer, easier way to donate!', 'easy_donate' ) . '" />
					<img src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="' . __( 'Donate with PayPal', 'easy_donate' ) . '" width="1" height="1" border="0" />
					<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHTwYJKoZIhvcNAQcEoIIHQDCCBzwCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBvBd2khFwrWdLwQd4Gk1v0dqhy4njlYPbNtr9m7LzugMrT56Cg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49fRXKjmmV8qCphwey-----END PKCS7-----" />
				</div>
			</form>';
		// And let's spit out our button on command.
		echo $button . "\n";
	}
}
// Should you be doing this?
if ( !current_user_can('manage_options') ) {
	die( __( 'ACCESS DENIED: Your don\'t have permission to do this.', 'easy_donate' ) );
} elseif ( $_POST['action'] && $_POST['action'] == 'update' ) {
	check_admin_referer('easy_donate_options');
	update_option( 'easy_donate_default_value', str_replace( array( "\r", "\n", "\t" ), '', strip_tags(stripslashes($_POST['default_value'])) ) );
	update_option( 'easy_donate_default_button', strip_tags(stripslashes($_POST['default_button'])) );
	$message = '<div id="message" class="updated fade"><p><strong>' . __( 'Options saved.', 'easy_donate' ) . "</strong></p></div>\n";
}
if ( $message ) {
	echo $message;
}
// And we being the actual menu HTML
$imgsurl = get_bloginfo('wpurl') . '/wp-content/plugins/easy-donate/images';
$checked = 'checked="checked" ';
?>
<div class="wrap">
	<h2><?php _e( 'Easy Donate', 'easy_donate' ) ?></h2>
	<?php if ( function_exists('plaintxt_plugin_donate') ) plaintxt_plugin_donate(); // Let them donate. ?>
	<p><?php _e( 'Thank you for using this <a href="http://www.plaintxt.org/" title="plaintxt.org">plaintxt.org</a> plugin. When deactivating this plugin, its settings will be permanently deleted from you database.', 'easy_donate' ) ?></p>
	<form method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
		<?php wp_nonce_field('easy_donate_options'); echo "\n"; // Very important for security. Do not fool with this. ?>
		<h3><?php _e( 'Shortcode Settings', 'easy_donate' ) ?></h3>
		<table class="form-table" summary="<?php _e( 'Add button value', 'easy_donate' ) ?>">
			<tr valign="top">
				<th scope="row"><label for="default_value"><?php _e( 'Default value', 'easy_donate' ) ?></label></th>
				<td>
					<fieldset>
						<legend class="hidden"><?php _e( 'Default value', 'easy_donate' ) ?></legend>
						<textarea id="default_value" name="default_value" rows="6" cols="50" class="code" style="font-size:11px;width:95%;"><?php echo str_replace( array( "\r", "\n", "\t" ), '', attribute_escape(get_option('easy_donate_default_value')) ) ?></textarea><br />
						<?php _e( 'Set the default encrypted input <code>value</code>. You may specify other values, i.e., different donate buttons, with the <code>value</code> attribute in the <code><span>[</span>easy-donate<span>]</span></code> shortcode. You must use the <em>encrypted</em> value generated by Paypal.', 'easy_donate' ) ?>
					</fieldset>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php _e( 'Default button', 'easy_donate' ) ?></th>
				<td class="defaultavatarpicker">
					<fieldset>
						<legend class="hidden"><?php _e( 'Default button', 'easy_donate' ) ?></legend>
						<label><input id="button_1" name="default_button" type="radio" value="1" <?php if ( get_option('easy_donate_default_button') == 1 ) echo $checked; ?>/> [1] <img src="<?php echo $imgsurl; ?>/btn_donate_LG.gif" alt="1" height="26" width="92" class="avatar" /></label><br />
						<label><input id="button_2" name="default_button" type="radio" value="2" <?php if ( get_option('easy_donate_default_button') == 2 ) echo $checked; ?>/> [2] <img src="<?php echo $imgsurl; ?>/btn_donate_SM.gif" alt="2" height="21" width="74" class="avatar" /></label><br />
						<label><input id="button_3" name="default_button" type="radio" value="3" <?php if ( get_option('easy_donate_default_button') == 3 ) echo $checked; ?>/> [3] <img src="<?php echo $imgsurl; ?>/btn_donateCC_LG.gif" alt="3" height="47" width="122" class="avatar" /></label><br />
						<label><input id="button_4" name="default_button" type="radio" value="4" <?php if ( get_option('easy_donate_default_button') == 4 ) echo $checked; ?>/> [4] <img src="<?php echo $imgsurl; ?>/x-click-but04.gif" alt="4" height="31" width="62" class="avatar" /></label><br />
						<label><input id="button_5" name="default_button" type="radio" value="5" <?php if ( get_option('easy_donate_default_button') == 5 ) echo $checked; ?>/> [5] <img src="<?php echo $imgsurl; ?>/x-click-but11.gif" alt="5" height="23" width="60" class="avatar"/></label><br />
						<label><input id="button_6" name="default_button" type="radio" value="6" <?php if ( get_option('easy_donate_default_button') == 6 ) echo $checked; ?>/> [6] <img src="<?php echo $imgsurl; ?>/x-click-but21.gif" alt="6" height="23" width="110" class="avatar" /></label><br />
						<label><input id="button_7" name="default_button" type="radio" value="7" <?php if ( get_option('easy_donate_default_button') == 7 ) echo $checked; ?>/> [7] <img src="<?php echo $imgsurl; ?>/x-click-butcc-donate.gif" alt="7" height="44" width="73" class="avatar" /></label><br />
						<p><?php _e( 'Set the default image to show. You may specify a different image using the number above with the <code>button</code> attribute in the <code><span>[</span>easy-donate<span>]</span></code> shortcode, e.g., <code><span>[</span>easy-donate button="2"<span>]</span></code>.', 'easy_donate' ) ?></p>
					</fieldset>
				</td>
			</tr>
		</table>
		<p class="submit">
			<input name="update" type="submit" value="<?php _e( 'Save Changes', 'easy_donate' ) ?>" />
			<input name="action" type="hidden" value="update" />
			<input name="page_options" type="hidden" value="default_value,default_button" />
		</p>
	</form>
</div>